<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>充值</title>
		<script src="../js/mui.js"></script>
		<link href="../css/mui.css" rel="stylesheet" />
		<script type="text/javascript" charset="utf-8">
			mui.init();
			if(location.pathname != "/h5/html/login.html" && typeof(sessionStorage.token) == "undefined") {

				mui.openWindow({
					url: 'login.html',

				});
			}
		</script>
		<link rel="stylesheet" href="../css/common.css" />
		<link rel="stylesheet" href="../css/reg.css" />
		<script type="text/javascript" src="../js/common.js"></script>
		<style>
			#btn {
				margin-top: 1rem;
			}
			
			#btn button {
				width: 3.4rem;
				height: 0.88rem;
			}
		</style>
	</head>

	<body>
		<div class="mui-content">
			<form class="mui-input-group">
				<div class="mui-input-row">
					<label>金额</label>
					<input type="text" class="mui-input-clear withdrawalMoney" placeholder="&nbsp;100的倍数">
				</div>
				<div class="mui-input-row">
					<label>银行卡</label>
					<select style="color:#BFC0C1;" class="mycard">
						<option value="none">请选择您已绑定的银行卡</option>

					</select>
					<img src="../images/bottom.png" style="position: absolute;right: 0.1rem;top: 0.16rem;width: 20px;height: 20px;" />
				</div>

				<div class="mui-input-row">
					<label>支付密码</label>
					<input type="password" class="mui-input-clear payPassword" placeholder="请输入支付密码">
				</div>
				<div class="mui-input-row">
					<label>备注</label>
					<input type="text" class="mui-input-clear" placeholder="请输入备注">
				</div>
			</form>
			<div class="mui-content-padded " id="btn">
				<button type="button" class="mui-btn mui-btn-danger" style="margin-right: 0.1rem;height: 1rem;">普通提现</button>
				<button type="button" class="mui-btn mui-btn-danger" style="height: 1rem;">快速提现</button>
			</div>

		</div>

	</body>

</html>
<script>
	if(sessionStorage.isVerify == "false") {
		mui.openWindow({
			url: 'id.html',
		});
	}
	//实名认证跳转
	mui.ajax('/api/v1/bank/myCardList', {
		data: {
			paramStr: "{'userName':'" + sessionStorage.userName + "','token':'" + sessionStorage.token + "'}"
		},
		dataType: 'json',
		type: 'post',
		timeout: 10000,

		success: function(data) {
			var obj = eval('(' + data.data + ')');
			var i;
			if(data.code == 200) {

				for(i in obj.myCardList) {

					var mycard = document.querySelector(".mycard")
					var option = document.createElement("option");
					option.value = obj.myCardList[i].id;
					mycard.appendChild(option);
					option.innerHTML = obj.myCardList[i].bank_name + obj.myCardList[i].bank_card;
				}
			}

		},
		error: function(xhr, type, errorThrown) {
			//异常处理；
			mui.toast("未知错误4")
		}
	});
	//银行卡拉取
	document.getElementById("btn").addEventListener("tap", function() {
		var payPassword = document.querySelector(".payPassword").value;
		var withdrawalMoney = document.querySelector(".withdrawalMoney").value;
		var userBankId = document.querySelector(".mycard").value;
		mui.ajax('/api/v1/finance/transfer/withdrawl', {
			data: {

				paramStr: "{'userName':'" + sessionStorage.userName + "','token':'" + sessionStorage.token + "','withdrawalMoney':'" + withdrawalMoney + "','payPassword':'" + payPassword + "','userBankId':'" + userBankId + "'}"
			},
			dataType: 'json',
			type: 'post',
			timeout: 10000,

			success: function(data) {
				var obj = eval('(' + data.data + ')');

				if(data.code == 200) {
					mui.alert(data.message, jump);

					function jump() {
						mui.openWindow({
							url: '../index.html',
						});
					}
				}

			},
			error: function(xhr, type, errorThrown) {
				//异常处理；
				mui.toast("未知错误4")
			}
		});

	})
</script>